package com.web.java0328springboot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.web.java0328springboot.entity.User;
import com.web.java0328springboot.mapper.UserMapper;
import com.web.java0328springboot.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 用户service实现类
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public User login(String username, String password) {
        //通过用户名称查询用户
        User user = userMapper.selectOne(new QueryWrapper<User>().lambda()
                .eq(User::getUsername, username));
        if(user != null){
            //判断密码是否正确
            if(user.getPassword().equals(password)){
                return user;
            }
        }
        return null;
    }
}
